package com.isoftstone.service.Impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.isoftstone.dao.MenuDao;
import com.isoftstone.entity.Menu;
import com.isoftstone.entity.Role;
import com.isoftstone.service.MenuService;

@Service("MenuService")
public class MenuServiceImpl implements MenuService {
	@Autowired
	private MenuDao menuDao;

	@Override
	public List<Menu> getAllMenuList() {
		// TODO Auto-generated method stub
		return menuDao.getAllMenuList();
	}

	@Override
	public boolean insertMenu(Menu menu) {
		// TODO Auto-generated method stub
		String menuId=menu.getMenuId();
		String menuName=menu.getMenuName();
		String parentId=menu.getParentId();
		String menuUrl=menu.getMenuUrl();
		if(menuId!=null){
			boolean flag =menuDao.insertMenu(menuId,menuName,parentId,menuUrl);
			if(flag){
				return true;
			}
		}
		return false;	
	}

	@Override
	public boolean deleteMenu(String menuId) {
		// TODO Auto-generated method stub
		if(menuId!=null ){
			boolean flag =menuDao.deleteMenu(menuId);
			if(flag){					
				return true;				
			}		
		}
		return false;
	}

	@Override
	public Menu getMenuByMenuId(String menuId) {
		// TODO Auto-generated method stub
		Menu menu =menuDao.getMenuByMenuId(menuId);
		return menu;
	}

	@Override
	public boolean editMenu(Menu menu) {
		// TODO Auto-generated method stub
		String menuId=menu.getMenuId();
		String menuName=menu.getMenuName();
		String parentId=menu.getParentId();
		String menuUrl=menu.getMenuUrl();
		if(menuId!=null){
			boolean flag =menuDao.editMenu(menuId,menuName,parentId,menuUrl);
			if(flag){
				return true;
			}
		}
		return false;	
	}

}
